using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SheetManager {
	
	public static CharacterSheet activeCharacter;
	
	static string typeName = typeof(CharacterSheet).ToString();
	
	static GenericManager<CharacterSheet> _m;
	
	public static bool activeCharacterUpdated = false;
	
	static GenericManager<CharacterSheet> m
	{
		get
		{
			if(_m == null)
				_m = new GenericManager<CharacterSheet>(typeName);
			return _m;
		}
	}
	
	public static Dictionary<string,string> index
	{
		get
		{
			return m.index;
		}
	}
	
	public static bool SaveActiveCharacter(bool updateLists = true)
	{
		activeCharacterUpdated = updateLists;
		return m.SaveObject(activeCharacter, activeCharacter.fileName);
	}

	public static CharacterSheet LoadCharacter(string infoTarget)
	{
		activeCharacter = m.LoadObject(infoTarget);
		return activeCharacter;
	}

	public static void DeleteCharacter (string infoTarget)
	{
		m.DeleteObject(infoTarget);
	}
		
	public static CharacterSheet AddCharacter(string name, string gender, string description)
	{
		CharacterSheet a = new CharacterSheet();
		a.name = name;
		a.description = description;
		a.Gender = gender;
		
		a.race = new Race();
		
		a.classes = new List<CharacterClass>();
		
		a.Damage = 0;
		a.bonusHP = 0;
		a.Experience = 0;
		
		a.Alignment = "Neutral";
		a.weapons = new List<WeaponItem>();
		a.skills = new List<Skill>();
		a.addedFeats = new List<Ability>();
		a.addedSpecialAbilities = new List<Ability>();
		a.inventories = new List<InventoryItem>();
				
		a.progressionSpeed = "Fast";
		
		a.extraInfo = new ExtendedCharacterStats();
		
		return m.AddObject(a);
	}
}
